import { Server } from 'socket.io'
import http from 'http'
import type { Http2ServerRequest, Http2ServerResponse } from 'http2'

export class Soket {
  koaCallback: (
    req: http.IncomingMessage | Http2ServerRequest,
    res: http.ServerResponse | Http2ServerResponse
  ) => void
  server: http.Server
  socketIo: Server
  constructor(koaCallback) {
    this.koaCallback = koaCallback
    this.init()
  }

  init() {
    this.server = http.createServer(this.koaCallback)
    this.socketIo = new Server(this.server, {})

    this.socketIo.sockets.on('connection', async client => {
      console.log(client)
    })
  }
}
